import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 按钮
class ComButton extends StatelessWidget {
  final String text;
  final Color textColor;
  final Color bgColor;
  final bool enableBorder;
  final double borderRadius;
  final Color borderColor;
  final Function()? onTap;

  const ComButton({
    super.key,
    required this.text,
    required this.textColor,
    required this.bgColor,
    this.borderRadius = 20,
    this.enableBorder = false,
    this.borderColor = Colors.white10,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
      child: Material(
        color: bgColor,
        child: InkWell(
          borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
          onTap: onTap,
          child: Container(
            decoration: BoxDecoration(
              border: enableBorder ? Border.all(color: borderColor) : null,
              borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
            ),
            padding: EdgeInsets.symmetric(horizontal: 12.r, vertical: 8.r),
            child: Text(
              text,
              style: TextStyle(fontSize: 12.r, color: textColor),
              textAlign: TextAlign.center,
            ),
          ),
        ),
      ),
    );
  }
}
